<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"><meta name="referrer" content="no-referrer" />
    <title>用户管理页面</title>
    <script src="js/jquery-1.11.0.min.js"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <style>
        .submenu > ul {
            display: none;
        }

        .open > ul {
            display: block;
        }
    </style>
    <script>
        $(function () {
            console.log("进入头部");
            $(".header").load("adminHeadHtml");
            console.log("展示公告！");
            $.post("/getAdminName", function (obj) {
                $.ajax({
                    url: "/getUsers",
                    type: "POST",
                    success: function (result) {
                        console.log("---------");
                        console.log(result);
                        console.log("---------");
                        if (result != null) {
                            $imgs = $("#navul");
                            var li = '';
                            for (let i = 0; i < result.length; i++) {
                                li = li + '<tr>\n' +
                                    '<th>' + (i + 1) + '</th>\n' +
                                    '<th>' + result[i].username + '</th>\n';
                                if(result[i].jubao>10){
                                    li = li + '<th style="padding: ">用户被举报次数过多</th>\n';
                                }else{
                                    li = li + '<th>' + result[i].jubao + '</th>\n';
                                }
                                if(result[i].com_aut===1){
                                    li = li + '<th><button onclick="jinyan(' + result[i].id + ')">禁言</button></th>\n';
                                }else{
                                    li = li + '<th><button onclick="jinyan(' + result[i].id + ')">解除</button></th>\n';
                                }
                                li = li + '</tr>';
                            }
                            $imgs.html(li);
                        }
                    }
                })
            }, "json");
        });
        function jinyan(a){
            if (confirm("确认进行该操作吗？确定不是手滑了点错了吗？")){
                $.ajax({
                    url: "/jinyan",
                    type: "POST",
                    contentType: "application/json",
                    dataType:"json",
                    data: JSON.stringify({"id": a}),//划重点
                    success: function (result) {
                        console.log("---------");
                        console.log(result);
                        console.log("---------");
                        if (result) {
                            confirm("操作成功！");
                        }else {
                            confirm("操作失败！");
                        }
                        location.reload();
                    }
                })
            }
        }
        function jiechu(a){

        }
    </script>
    <script>
        $(function () {
            $('.submenu').mouseover(function () {
                $(this).addClass('open');
            }).mouseout(function () {
                $(this).removeClass('open');
            });
        })
    </script>
</head>
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">
            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <h1 style="text-align: center;color: #33cabb;">Spider</h1>
            </div>
            <div class="lyear-layout-sidebar-scroll">
                <nav class="sidebar-main">
                    <ul class="nav nav-drawer" style="list-style: none">
                        <li class="nav-item active"><a href="/adminNotice"><i class="mdi mdi-home"></i>公告管理</a></li>
                        <li class="nav-item active"><a href="/toFindAllUsers"><i class="mdi mdi-home"></i>用户管理</a></li>
                        <li class="nav-item active"><a href="/adminComment"><i class="mdi mdi-home"></i>查看反馈</a></li>
                        <li class="nav-item active submenu"><a href="#"><i class="mdi mdi-home"></i>个人中心</a>
                            <ul class="nav nav-drawer">
                                <li class="nav-item active"><a href="/toSelf">&nbsp&nbsp&nbsp&nbsp<i
                                        class="mdi mdi-step-forward"></i>信息编辑</a></li>
                            </ul>
                        </li>
                    </ul>
                </nav>
            </div>
        </aside>
        <!--End 左侧导航-->
        <!--头部信息-->
        <div class="header"></div>
        <!--End 头部信息-->
        <!-- 主题内容 -->
        <!--页面主要内容 table table-striped table-hover-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>用户名</th>
                                    <th>被举报数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="navul">
                                <tr>
                                    <th></th>
                                    <th></th>
                                    <th></th>
                                    <th>
                                        <button>禁言</button>
                                        <button>解除禁言</button>
                                    </th>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>
</body>
</html>